<template>
	<view class="page-content">
		<view class="page-title">基本使用</view><ui-br />
		<view class="page-tips">在方法中调用</view><ui-br />
		<ui-code :code="code"></ui-code><ui-br />
		
		<view class="page-title">案例</view><ui-br />
		<ct-button @click="updatePic" width="200rpx">上传</ct-button><ui-br />
		<view v-if="base64">
			<image style="width: 300rpx;" :src="base64" mode="widthFix"></image>
		</view>
		<ct-cropping ref="cropping" />
	</view>
</template>

<script>
	import code from './code.js';
	export default {
		data(){
			return{
				base64:"",
				code:""
			}
		},
		created() {
			this.code = code
		},
		methods:{
			updatePic(){
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res)=> {
						this.$refs['cropping'].open({
							imgUrl:res.tempFilePaths[0],
							isNavbar:false,
							confirm:(e)=>{
								this.base64 = e
							},
							cancel:(e)=>{}
						})
					}
				});

			}
		}
	}
</script>

<style>
</style>